
#include "stdafx.h"
#include <assert.h>
#include "DA6208.h"

DA6208::DA6208()
{

}

DA6208::~DA6208()
{
	Release_Card (m_h6208);
}

BOOL DA6208::INIT6208()
{
	if (m_h6208 >= 0) Release_Card(m_h6208);
	m_h6208 = Register_Card(PCI_6208V, CARD_NO);

	if(m_h6208 < 0) return FALSE;

	for(int i=0; i<MAXCH_NO; i++)
	{
		m_dCurValue[i] = 0.0;
		//AO_WriteChannel(m_h6208, i, m_dCurValue[i]);
	}
	SetValue(0,10.0);
	return TRUE;	
}

short DA6208::GetDA6208()
{
	return m_h6208;
}

int DA6208::SetValue(short iDAConverterID, double val)
{
	if(val < 0) val = 0.0;
	else if(val > 10.0) val = 10.0;

	int ret = AO_VWriteChannel(m_h6208, iDAConverterID, val);//*20.0)+0.1);
	if(ret != NoError) return ret;

	m_dCurValue[iDAConverterID] = val;
	return 0;
}

double DA6208::GetValue(short iDAConverterID)
{
	return m_dCurValue[iDAConverterID]; 
}
